import 'package:flutter/material.dart';
import 'package:flutter_wanandroid/pages/flutter_webview.dart';
import 'package:fluttertoast/fluttertoast.dart';

class AboutPage extends StatefulWidget {
  const AboutPage({Key? key}) : super(key: key);

  @override
  State<AboutPage> createState() => _AboutPageState();
}

class _AboutPageState extends State<AboutPage> {
  var _list = <String>[
    "fluttertoast",
    "dio",
    "cookie_jar",
    "flutter_webview_plugin",
    "flutter_swiper",
    "share",
    "provide",
    "shared_preferences",
    "flutter_easyrefresh",
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            backgroundColor: Theme.of(context).primaryColor,
            title: const Text("关于项目"),
            expandedHeight: 230,
            pinned: true,
            floating: false,
            snap: false,
            actions: [
              PopupMenuButton(
                  icon: const Icon(Icons.more_horiz),
                  offset: const Offset(100, 100),
                  itemBuilder: (BuildContext context) {
                    return <PopupMenuEntry<String>>[
                      const PopupMenuItem(
                        value: "1",
                        child: ListTile(
                          leading: Icon(Icons.share),
                          title: Text("分享"),
                        ),
                      ),
                      const PopupMenuDivider(),
                      const PopupMenuItem(
                        value: "2",
                        child: ListTile(
                          leading: Icon(Icons.settings),
                          title: Text("设置"),
                        ),
                      ),
                    ];
                  },
                  tooltip: "点击弹出菜单",
                  onSelected: (String result) {
                    switch (result) {
                      case "1":
                        Fluttertoast.showToast(msg: "分享");
                        break;
                      case "2":
                        Fluttertoast.showToast(msg: "设置");
                        break;
                    }
                  }),
            ],
            flexibleSpace: FlexibleSpaceBar(
              background: Image.network(
                "https://profile-avatar.csdnimg.cn/f81b97e9519148ac9d7eca7681fb8698_yechaoa.jpg!1",
                fit: BoxFit.cover,
              ),
            ),
          ),
          SliverFixedExtentList(
            delegate: SliverChildBuilderDelegate((context, index) {
              return Padding(
                padding: const EdgeInsets.all(20),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(
                        "android_flutter V2.0",
                        style: TextStyle(
                          fontSize: 25,
                          fontFamily: 'mononoki',
                          fontWeight: FontWeight.normal,
                        ),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.all(10),
                      child: Text(
                        "Author ：yechaoa",
                        style: TextStyle(
                          decoration: TextDecoration.underline,
                          //下划线
                          decorationStyle: TextDecorationStyle.wavy,
                          //下划线样式：波浪线
                          fontSize: 18,
                          fontWeight: FontWeight.normal,
                          color: Theme.of(context).primaryColor,
                        ),
                      ),
                    ),
                    const Divider(),
                    ListTile(
                      title: const Text(
                        "GitHub",
                        style: TextStyle(
                          fontSize: 18,
                        ),
                      ),
                      trailing: const Icon(Icons.chevron_right),
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) {
                            return FlutterWebView(
                                title: "别跑，点个star再走~🌹",
                                uri:
                                    "https://github.com/yechaoa/wanandroid_flutter");
                          }),
                        );
                      },
                    ),
                    const Divider(),
                    ListTile(
                      title: const Text(
                        "掘金",
                        style: TextStyle(
                          fontSize: 18,
                        ),
                      ),
                      trailing: const Icon(Icons.chevron_right),
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) {
                            return FlutterWebView(
                                title: "yechaoa's 掘金",
                                uri:
                                    "https://juejin.cn/user/659362706101735/posts");
                          }),
                        );
                      },
                    ),
                    const Divider(),
                    ListTile(
                      title: const Text(
                        "CSDN",
                        style: TextStyle(
                          fontSize: 18,
                        ),
                      ),
                      trailing: const Icon(Icons.chevron_right),
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(builder: (context) {
                            return FlutterWebView(
                                title: "yechaoa's CSDN",
                                uri: "https://blog.csdn.net/yechaoa");
                          }),
                        );
                      },
                    ),
                    const Divider(),
                    const Padding(
                      padding: EdgeInsets.all(10),
                      child: Text(
                        "用到的库：",
                        style: TextStyle(fontSize: 16),
                      ),
                    ),
                    ListView.builder(
                        itemCount: _list.length,
                        physics: const NeverScrollableScrollPhysics(),
                        shrinkWrap: true,
                        itemBuilder: (context, index) {
                          return Padding(
                            padding: const EdgeInsets.symmetric(
                                vertical: 20, horizontal: 50),
                            child: Text(
                              _list[index],
                            ),
                          );
                        }),
                  ],
                ),
              );
            }, childCount: 1),
            itemExtent: 900.0,
          )
        ],
      ),
    );
  }
}
